package com.epalmpay.controller.manage.datareport;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.epalmpay.commom.BaseController;
import com.epalmpay.exception.ApplicationException;
import com.epalmpay.status.Rescode;
import com.epalmpay.dto.manage.datareport.TradeDetailInDTO;
import com.epalmpay.dto.manage.datareport.TradeDetailListOutDTO;
import com.epalmpay.dto.manage.datareport.TradeDetailOutDTO;
import com.epalmpay.dto.manage.datareport.TradeStatisShopDayOutDTO;
import com.epalmpay.dto.system.PageDTO;
import com.epalmpay.entity.Page;
import com.epalmpay.entity.StatisShopMonth;
import com.epalmpay.service.datareport.ITradeDetailService;
import com.epalmpay.util.Tools;


/** 
 * 说明：掌富报表管理
 * 创建人：gwn
 * 创建时间：2017-06-29
 */
@Controller
@RequestMapping(value="/manager/dataReport")
public class TradeDetailController  extends BaseController{
		
		@Resource
		private ITradeDetailService tradeDetailService;
		
		
	
		@RequestMapping(value="/tradeDetail")
		@ResponseBody
		public TradeDetailListOutDTO  tradeDetail(TradeDetailInDTO tradeDetailInDTO,PageDTO pageDTO){
			TradeDetailListOutDTO tradeDetailListOutDTO=new TradeDetailListOutDTO();
			try {
				Page page=Tools.pageEmtity(pageDTO);
				//获取交易明细列表
				List<TradeDetailOutDTO> tradeDetailOutDTO = tradeDetailService.queryTradeDetailList(tradeDetailInDTO,page);			
				tradeDetailListOutDTO.setTradeDetailOutDTOList(tradeDetailOutDTO);
				tradeDetailListOutDTO.setPage(page); 
				tradeDetailListOutDTO.setErrorCode(Rescode.SUCCESS, "处理成功");
				return tradeDetailListOutDTO;
			} catch (ApplicationException ae) { 
				tradeDetailListOutDTO.setErrorCode(ae.errCode, ae.errMsg);
				ae.printStackTrace();
			}
			 catch (Exception e) { 
				 tradeDetailListOutDTO.setErrorCode(Rescode.DEFAULT_PREFIX, "处理出现异常");
				e.printStackTrace();
			}
			return tradeDetailListOutDTO;
		}		
		

		
		/**
		 * 查看日详情
		 * @param 
		 * @param pageDTO
		 * @return
		 */
		@RequestMapping(value="/queryDayDetail")
		@ResponseBody
		public TradeDetailListOutDTO  queryDetail (TradeDetailInDTO TradeDetailInDTO,PageDTO pageDTO){
			TradeDetailListOutDTO tradeDetailListOutDTO=new TradeDetailListOutDTO();
			try {
				Page page=Tools.pageEmtity(pageDTO);
				
				StatisShopMonth statisShopMonth =new StatisShopMonth();
				statisShopMonth=tradeDetailService.queryStatisShopMonthById(TradeDetailInDTO.getId());
				tradeDetailListOutDTO.setStatisShopMonth(statisShopMonth);
				
				TradeDetailInDTO.setStringStatisDate(statisShopMonth.getStatisDate());
				TradeDetailInDTO.setShopId(statisShopMonth.getShopId());
				
				//总条数
				List<TradeStatisShopDayOutDTO> tradeStatisShopDayOutDTOList = tradeDetailService.queryStatisShopDayList(TradeDetailInDTO,page);	
				tradeDetailListOutDTO.setTradeStatisShopDayOutDTOList(tradeStatisShopDayOutDTOList);
				tradeDetailListOutDTO.setPage(page); 
				tradeDetailListOutDTO.setErrorCode(Rescode.SUCCESS, "处理成功");
				return tradeDetailListOutDTO;
			} catch (ApplicationException ae) { 
				tradeDetailListOutDTO.setErrorCode(ae.errCode, ae.errMsg);
				ae.printStackTrace();
			}
			 catch (Exception e) { 
				 tradeDetailListOutDTO.setErrorCode(Rescode.DEFAULT_PREFIX, "处理出现异常");
				e.printStackTrace();
			}
			return tradeDetailListOutDTO;
		}	
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
}
